package com.stone.aidlserver;

import android.app.Dialog;
import android.content.Context;
import android.database.DataSetObserver;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Adapter;
import android.widget.ListView;
import android.widget.Toast;

import org.apache.commons.lang3.concurrent.BasicThreadFactory;

import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Timer timer = new Timer();
        TimerTask timerTask = new TimerTask() {
            @Override
            public void run() {

                // 定时完成要做的事
                Log.e("Stone", "run(MainActivity.java:29)-->>"+"timer");
                int a = 0;
                Toast.makeText(MainActivity.this, "Stone", Toast.LENGTH_SHORT);

            }
        };
        timer.schedule(timerTask, 1000);

        Log.e("Stone", "run(MainActivity.java:29)-->>"+"timer");
        final ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(1,
                new BasicThreadFactory.Builder().namingPattern("example-schedule-pool-%d").daemon(true).build());
        executorService.scheduleAtFixedRate(new Runnable() {
            @Override
            public void run() {
                //do something
                Log.e("Stone", "run(MainActivity.java:39)-->>"+"小菜鸟");
                executorService.shutdown();
            }
        },10,5, TimeUnit.SECONDS);

    }







}
